import request from '@/utils/request'

export function fetchList(query) {
  return request({
    url: '/article/index',
    method: 'get',
    params: query
  })
}

export function fetchArticle(id) {
  return request({
    url: '/article/show',
    method: 'get',
    params: { id }
  })
}

export function fetchPv(pv) {
  return request({
    url: '/article/pv',
    method: 'get',
    params: { pv }
  })
}

export function createArticle(data) {
  return request({
    url: '/article/store',
    method: 'post',
    data
  })
}

/**
 * 删除文章
 * @param data  要删除的文章ID或数组
 */
export function deleteArticle(ids) {
  return request({
    url: '/article/delete',
    method: 'post',
    data: { ids }
  })
}

export function updateArticle(data) {
  return request({
    url: '/article/update',
    method: 'post',
    data
  })
}

/**
 * 文章分类
 */
export function getCategory() {
  return request({
    url: '/article/category'
  })
}
